package com.ss.android.newmedia.message;

import android.content.Context;
import android.util.Pair;

import com.bytedance.common.plugin.interfaces.pushmanager.IMessageDepend;
import com.bytedance.common.plugin.interfaces.pushmanager.IPushLifeCycleListener;
import com.bytedance.common.utility.Logger;
import com.bytedance.ttnet.a.AppConfig;
import com.ss.android.common.app.AppHooks;
import com.ss.android.common.app.AppHooks.InitHook;
import com.ss.android.common.applog.AppLog;
import com.ss.android.common.util.CommonConstants;
import com.ss.android.messagebus.Subscriber;
import com.ss.android.messagebus.SubscriptionRouter;
import com.ss.android.newmedia.BaseAppData;

import org.json.JSONObject;

import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

import inline.TempBean;

public class g implements IMessageDepend {
    private static volatile g a;
    private static final Queue b;
    private static boolean c;

    static {
        CommonConstants.srv("/service/2/app_notify/");
        CommonConstants.buildUrl("/push/get_service_addrs/");
        CommonConstants.buildUrl("/promotion/app/lt/");
        CommonConstants.buildUrl("/service/1/update_token/");
        CommonConstants.buildUrl("/cloudpush/callback/android_red_badge/");
        b = new LinkedBlockingQueue();
        c = true;
    }

    private g() {
        SubscriptionRouter.addSubscriber(this);
    }

    public static g a() {
        if (g.a == null) {
            Class v1 = g.class;
            synchronized (v1) {
                if (g.a == null) {
                    g.a = new g();
                }
            }
        }

        return g.a;
    }

    public int checkHttpRequestException(Throwable arg2, String[] arg3) {
        return android.support.design.a.a(arg2, arg3);
    }

    public String filterUrl(Context arg3, String arg4) {
        return AppConfig.getInstance(arg3).a(arg4, null);
    }

    public Pair getAliyunPushConfig() {
        return null;
    }

    public IPushLifeCycleListener getIPushLifeCycleListener() {
        return r.a();
    }

    public Pair getMiPushConfig() {
        return new Pair("2882303761517632089", "5961763288089");
    }

    public Pair getMzPushConfig() {
        return new Pair("111545", "7fd07cddafa7442d8f58144b6cf81a6f");
    }

    public String getSessionKey() {
        return AppLog.h();
    }

    public void onClickNotPassThroughNotification(Context arg7, int arg8, String arg9, int arg10, String arg11) {
        Logger.d("Push", "onClickNotPassThroughNotification() called with: context = [" + arg7 + "], type = [" + arg8 + "], obj = [" + arg9 + "], from = [" + arg10 + "], extra = [" + arg11 + "]");
        i.a(arg7, arg9, BaseAppData.inst(), arg10, arg11, false);
    }

    public void onEvent(Context arg4, String arg5, String arg6, String arg7, long arg8, long arg10, JSONObject arg12) {
        Logger.d("MessageDepend", "onEvent() called with: context = [" + arg4 + "], category = [" + arg5 + "], tag = [" + arg6 + "], label = [" + arg7 + "], value = [" + arg8 + "], ext_value = [" + arg10 + "], ext_json = [" + arg12 + "]");
        AppLog.onEvent(arg5, arg6, arg7, arg8, arg10, arg12);
    }

    public void onEventV3(String arg1, JSONObject arg2) {
        android.support.design.a.onEvent(arg1, arg2);
    }

    @Subscriber
    public void onMonitorInited$38c45720(TempBean arg3) {
        try {
            if (!Logger.debug()) {
                return;
            }

            Logger.d("MessageDepend", "onMonitorInited");
        } catch (Throwable v0) {
        }
    }

    public void sendMonitor(Context arg4, String arg5, JSONObject arg6) {
        if (arg4 != null && !android.support.design.a.isTextEmpty(arg5) && arg6 != null) {
            try {
                arg6.put("myself_push", AppLog.a(2));
                arg6.put("mi_push", AppLog.a(1));
                arg6.put("umeng_push", AppLog.a(6));
                arg6.put("mz_push", AppLog.a(8));
                arg6.put("hw_push", AppLog.a(7));
                if (g.c) {
                    if (Logger.debug()) {
                        Logger.d("MessageDepend", " logType = " + arg5 + " json = " + arg6);
                    }

                    com.bytedance.article.common.a.g.a(arg5, arg6);
                    return;
                }

                if (Logger.debug()) {
                    Logger.d("MessageDepend", "addToMonitor enqueue");
                }

                g.b.offer(new Pair(arg5, arg6));
            } catch (Throwable v0) {
                v0.printStackTrace();
            }
        }
    }

    public void tryHookInit(Context arg2) {
        try {
            InitHook v0_1 = AppHooks.getInitHook();
            if (v0_1 == null) {
                return;
            }

            v0_1.tryInit(arg2);
        } catch (Throwable v0) {
        }
    }
}

